cc.Class({
    extends: cc.Component,

    properties: {
        
    },
    onLoad(){
        //console.log("load")
        this.spine = this.getComponent('sp.Skeleton');
    },
    info (num) {
        
        //console.log("初始化倍率动画",num)
        switch (num) {
            case 1:
                this.spine.setSkin("blue")
                break;
            case 2:
                this.spine.setSkin("yellow")
                    break;
            default:
                this.spine.setSkin("pink")
                break;
        }
        
        //console.log("this.spine.setSkin(num)"+"   "+num)
        this.playSpine("oppen",false,this.onAnimationEnd("oppen"))

    },
    onAnimationEnd(param){
        if(param=="oppen"){
            this.spine.setAnimation(0, 'out', true)
        }
    },
    playSpine(animName, loop, callback) {
        let spine = this.spine
        let track = spine.setAnimation(0, animName, loop);
        if (track) {
            // 注册动画的结束回调
            spine.setCompleteListener((trackEntry, loopCount) => {
                let name = trackEntry.animation ? trackEntry.animation.name : '';
                if (name === animName && callback) {
                    callback(); // 动画结束后执行自己的逻辑
                }
            });
        }
    },
});
